[Error] E:\C语言实用程序150例【包括代码】\04\4.c:14: undefined reference to `randomize'

来源:百度知道 编辑:UC知道 时间:2024/07/02 19:17:53
#include "stdio.h" /*预编译命令,使用系统库函数时用到*/
#include "stdlib.h" /*应用random函数和randomize函数/
#include "ctype.h" /*应用toupper函数*/
main()
{
int count, /*猜数次数*/
number, /*随机被猜数*/
guess; /*所猜数字*/
char yes='Y';
printf("\nNow let us play the game.\n Guess the number:");
while(toupper(yes)=='Y')
{
count=0;
randomize();&&&&&&&&&&&&&&&&&&&&&
number=random(100)+1; /*产生随机数*/
do{
do{
printf("\nInput an integer number(1-100):");
scanf("%d",&guess);
}while(!(guess>=1&&guess<=100));
if(guess<number)

我猜你用的是vc6.0吧
你要随机获得一个数的话 在不同的编译器下面
用到的库函数不同
vc6.0下面的话 需要<time.h>
<stdlib.h>
然后是初始化随机种子 srand((unsigned)time(NULL));
再用 x=rand()%n
n为你想要随机获得的0~n-1的数,x为一个整型变量

再加个#include<time.h>头文件试一试